//
//  STHairInfoCell.m
//  YiYueStore
//
//  Created by zhouzhouzhou on 2018/10/15.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STHairInfoCell.h"
#import "AnotherStarEvaluator.h"

@implementation STHairInfoCell


- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // 初始化时加载collectionCell.xib文件
        NSArray *arrayOfViews =
        [[NSBundle mainBundle] loadNibNamed:@"STHairInfoCell"
                                      owner:self
                                    options:nil];
        
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}

-(void)setOwnCollectionCellWithData:(STHairBriefInfoModel *)data{
    if(![data isKindOfClass:[STHairBriefInfoModel class]]){
        return;
    }
        
    if (data.totalPerformance ||data.waitVerification || !data.position.length) {
        [self loadSelfHaireView:data];
    }else{
        [self loadOtherHaireView:data];
    }
    [self.headImg sd_setImageWithURL:[NSURL URLWithString:data.headPortrait] placeholderImage:[UIImage imageNamed:@"h-hairEg2"]];
    [self setStarView:data.star];
}

-(void)loadSelfHaireView:(STHairBriefInfoModel *)data{
    self.otherView.hidden = YES;
    self.selfView.hidden = NO;
    self.distanceBtn.hidden = YES;
    self.selfNameLab.text =data.nickname;
    self.orderIngLab.text =[NSString stringWithFormat:@"待核销订单：%d单",data.waitVerification];
    self.totalPerformance.text =[NSString stringWithFormat:@"累计完成业绩：¥%0.2f",data.totalPerformance];
    
    
}

-(void)loadOtherHaireView:(STHairBriefInfoModel *)data{
    self.otherView.hidden = NO;
    self.selfView.hidden = YES;
    self.distanceBtn.hidden = NO;
    self.nameLab.text =data.nickname;
    [self.positionBtn setTitle:data.position forState:UIControlStateNormal];
    [self.distanceBtn setTitle:[NSString stringWithFormat:@"%.0f",data.distance] forState:UIControlStateNormal];
    self.orderMonthNumLab.text=[NSString stringWithFormat:@"月接单/%d",data.monthOrder];
    self.priceLab.text = data.service;
    
}

-(void)setStarView:(float )starNum{
    AnotherStarEvaluator *starAllEva = [[AnotherStarEvaluator alloc] initWithFrame:self.starBackView.bounds];
    //    starAllEva.delegate = self;
    starAllEva.enabled=NO;
    [starAllEva setCurrentValue:starNum];
    [self.starBackView addSubview:starAllEva];
    [self.selfStarBackView addSubview:starAllEva];
    
    
    
    
    
}

@end
